package com.zhongjian.technologycal.mall.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.zhongjian.technologycal.mall.R;
import com.zhongjian.technologycal.mall.base.BaseContacts;
import com.zhongjian.technologycal.mall.bean.IDCardBean;

import java.util.List;


/**
 *
 */

public class IDCardAdapter extends BaseAdapter {
    private Context context;
    private List<IDCardBean> foodDatas;

    public IDCardAdapter(Context context, List<IDCardBean> foodDatas) {
        this.context = context;
        this.foodDatas = foodDatas;
    }

    @Override
    public int getCount() {
        if (foodDatas != null) {
            return foodDatas.size();
        } else {
            return 10;
        }
    }

    @Override
    public Object getItem(int position) {
        return foodDatas.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHold viewHold = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.items_idcard_dialog, null);
            viewHold = new ViewHold();
            viewHold.idcard_payment_tv_name =  convertView.findViewById(R.id.idcard_payment_tv_name);
            viewHold.idcard_iv_heading_photo =  convertView.findViewById(R.id.idcard_iv_heading_photo);
            convertView.setTag(viewHold);
        } else {
            viewHold = (ViewHold) convertView.getTag();
        }
        viewHold.idcard_payment_tv_name.setText(foodDatas.get(position).getData().get(position).getBankname());
        Uri uri = Uri.parse(BaseContacts.BASE_URL+foodDatas.get(position).getData().get(position).getLogo());
        Picasso.get().load(uri).into(viewHold.idcard_iv_heading_photo);
        return convertView;

    }

    private static class ViewHold {
        private TextView idcard_payment_tv_name;
        private ImageView idcard_iv_heading_photo;
    }

}
